package com.aaa.arouterone

import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProvider
import com.aaa.arouterone.test.Truck
import com.aaa.arouterone.testOcr.OCRbaiduTest
import com.aaa.arouterone.testRepository.MyViewModel
//import com.aaa.module2.Main2Activity
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.android.synthetic.main.activity_main.*
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import javax.inject.Inject

@AndroidEntryPoint
@Route(path = "/app/main")
class MainActivity : AppCompatActivity() {

    @Inject
    lateinit var truck: Truck

    @Inject
    lateinit var okHttpClient: OkHttpClient

    @Inject
    lateinit var retrofit: Retrofit

    /* @Inject
     lateinit var viewModel: MyViewModel*/
    val viewModel: MyViewModel by lazy {
        ViewModelProvider(this).get(MyViewModel::class.java)
    }


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        initView()
        initData()
    }

    private fun initData() {

    }

    private fun initView() {
        tv_1.setOnClickListener {
//            var intent = Intent(this, Main2Activity::class.java)
//            this.startActivity(intent)
            // 1.应用内简单的跳转(通过URL跳转在'进阶用法'中)
            ARouter.getInstance().build("/modules/main2").navigation()
        }
        button_1.setOnClickListener {
            // 2.跳转并携带参数
            ARouter.getInstance().build("/module3/main3")
                .withString("key3", "888")
                .navigation()
        }
        button_2.setOnClickListener {
            // 2.跳转并携带参数
            ARouter.getInstance().build("/app/mainVM")
//                .withString("key3", "888")
                .navigation()
        }
        iv_1.setOnClickListener {
            ARouter.getInstance().build("/module4/MainActivity4")
                .withString("strName1", "lfcsss")
                .withInt("showType", 10)
//                .withSerializable("objDataTest", TestBeans2())
                .navigation()
        }
        btn3.setOnClickListener {
            startActivity(Intent(this, OCRbaiduTest::class.java))
        }
        truck.deliver()
        Log.d("-lfc", "retrofit: " + retrofit.toString())

    }
}
